package eureka.domain.auction;

import java.io.Serializable;
import java.sql.Timestamp;

import eureka.domain.account.WebsiteUser;
import eureka.domain.book.BookItem;
import net.sf.json.JSON;
import net.sf.json.JSONSerializer;

public class Auction implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private long baID;
	private BookItem book;
	private AuctionState state;
	private float startingPrice;
	private float minimunMarkupPrice;
	private float currentPrice;
	private Timestamp startingDate;
	private Timestamp endingDate;
	private AuctionEndingReason endingReason;
	private WebsiteUser bidder;
	private long TransactionID;
	
	private float biddingPrice;
	

	public long getBaID() {
		return this.baID;
	}
	public void setBaID(long baID) {
		this.baID = baID;
	}

	public BookItem getBook() {
		return this.book;
	}
	public void setBook(BookItem book) {
		this.book = book;
	}

	public AuctionState getState() {
		return this.state;
	}
	public void setState(AuctionState state) {
		this.state = state;
	}
	public void setState(int nCode) {
		this.state = AuctionState.fromCode(nCode);
	}

	public float getStartingPrice() {
		return this.startingPrice;
	}
	public void setStartingPrice(float startingPrice) {
		this.startingPrice = startingPrice;
	}

	public float getMinimunMarkupPrice() {
		return this.minimunMarkupPrice;
	}
	public void setMinimunMarkupPrice(float minimunMarkupPrice) {
		this.minimunMarkupPrice = minimunMarkupPrice;
	}

	public float getCurrentPrice() {
		return this.currentPrice;
	}
	public void setCurrentPrice(float currentPrice) {
		this.currentPrice = currentPrice;
	}

	public Timestamp getStartingDate() {
		return this.startingDate;
	}
	public void setStartingDate(Timestamp startingDate) {
		this.startingDate = startingDate;
	}

	public Timestamp getEndingDate() {
		return this.endingDate;
	}
	public void setEndingDate(Timestamp endingDate) {
		this.endingDate = endingDate;
	}

	public AuctionEndingReason getEndingReason() {
		return this.endingReason;
	}
	public void setEndingReason(AuctionEndingReason endingReason) {
		this.endingReason = endingReason;
	}
	public void setEndingReason(int nCode) {
		this.endingReason = AuctionEndingReason.fromCode(nCode);
	}

	public WebsiteUser getBidder() {
		return this.bidder;
	}
	public void setBidder(WebsiteUser bidder) {
		this.bidder = bidder;
	}

	public long getTransactionID() {
		return this.TransactionID;
	}
	public void setTransactionID(long TransactionID) {
		this.TransactionID = TransactionID;
	}
	
	public float getBiddingPrice() {
		return biddingPrice;
	}
	public void setBiddingPrice(float biddingPrice) {
		this.biddingPrice = biddingPrice;
	}
	public static Auction getDefaultEmpty() {
		Auction a = new Auction();
		a.baID = 0;
		a.book = BookItem.getDefaultEmpty();
		a.state = AuctionState.Unknown;
		a.startingPrice = 0;
		a.minimunMarkupPrice = 0;
		a.currentPrice = 0;
		a.startingDate = null;
		a.endingDate = null;
		a.endingReason = AuctionEndingReason.Unknown;
		a.bidder = WebsiteUser.getDefaultEmpty();
		a.TransactionID = 0;
		return a;
	}

    public JSON toJSON() {
    	return JSONSerializer.toJSON(this);
    }

}
